package net.zjitc.controller;

import net.zjitc.aop.Pager;
import net.zjitc.context.LocalThreadHolder;
import net.zjitc.pojo.api.Result;
import net.zjitc.pojo.dto.query.extend.UserOperationLogQueryDto;
import net.zjitc.pojo.entity.UserOperationLog;
import net.zjitc.pojo.vo.UserOperationLogVO;
import net.zjitc.service.UserOperationLogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

//用户行为日志
@RestController
@RequestMapping(value = "/userOperationLog")
public class UserOperationLogController {

    @Resource
    private UserOperationLogService userOperationLogService;

    //用户行为日志新增
    @PostMapping(value = "/save")
    public Result<Void> save(@RequestBody UserOperationLog userOperationLog) {
        return userOperationLogService.save(userOperationLog);
    }

    //用户行为日志删除
    @PostMapping(value = "/batchDelete")
    public Result<Void> batchDelete(@RequestBody List<Integer> ids) {
        return userOperationLogService.batchDelete(ids);
    }

    //用户行为日志修改
    @PutMapping(value = "/update")
    public Result<Void> update(@RequestBody UserOperationLog userOperationLog) {
        return userOperationLogService.update(userOperationLog);
    }

    //用户行为日志，查询用户需要接收的
    @Pager
    @PostMapping(value = "/queryUser")
    public Result<List<UserOperationLogVO>> queryUser(@RequestBody UserOperationLogQueryDto dto) {
        dto.setUserId(LocalThreadHolder.getUserId());
        return userOperationLogService.query(dto);
    }

    //用户行为日志查询
    @Pager
    @PostMapping(value = "/query")
    public Result<List<UserOperationLogVO>> query(@RequestBody UserOperationLogQueryDto dto) {
        return userOperationLogService.query(dto);
    }

}
